package com.zoranjoka.chordis.hibernate;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Session;

import com.zoranjoka.chordis.Album;
import com.zoranjoka.chordis.beans.AlbumBean;

public class DataAlbumHibernate implements IDataAlbumService {

	private final Session session;
	
	public DataAlbumHibernate(Session session){
		this.session = session;
	}
	
	@Override
	public List<AlbumBean> getAllAlbums() {
		List getAll = session.createQuery("from AlbumBean").list();
		return getAll;
	}

	@Override
	public Album getAlbumByName(Serializable id) {
		return (Album) session.get(AlbumBean.class, id);
	}

	@Override
	public Album addAlbumBean(AlbumBean ab) {
		return (Album) session.get(AlbumBean.class, session.save(ab));
	}
	
}
